<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>短运司机信息列表</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/animate.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/style.min.css?v=4.1.0" rel="stylesheet">
    <style type="text/css">
    	#driverTab{
    		font-size: 15px;
    	}
    	#queryDriverForm label{padding:7px 0 0;}
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>司机信息列表</h5>
        </div>
        <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="example-wrap" style="position:relative;">
                        <!-- start toolbar -->
                        <div class="col-sm-12">
                            <form class="form-horizontal" role="form" id="queryDriverForm">
                        <div class="col-sm-12">
                            <form class="form-horizontal" role="form" id="queryDriverForm" autocomplete="off">
                                <div class="row">
                                 	<div class="col-sm-2">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">真实姓名</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" placeholder="真实姓名" id="driverRealName" name="driverRealName" autocomplete="off">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">手机号</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" placeholder="手机号" id="driverPhone" name="driverPhone" autocomplete="off">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">审核</label>
                                            <div class="col-sm-9">
                                                <select id="driverToExamine" name="driverToExamine" class="form-control">
                                                    <option value="">选择状态</option>
                                                    <option value="0">未审核</option>
                                                    <option value="1">通过</option>
                                                    <option value="2">未通过</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-4">
                                    	<button type="button" class="btn btn-primary" id="queryDriverBtn">
                                            <span class="glyphicon glyphicon-search" aria-hidden="true"></span> 查询
                                        </button>
                                        <shiro:hasPermission name="driver:add">
                                        	<!-- 是否有增加短运司机的权限 -->
                                        	<button class="btn btn-info" id="addBut" type="button">新增短运司机</button>
                                        </shiro:hasPermission>
                                        <button type="button" class="btn btn-info" id="" onclick="location.reload();">
                                            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 刷新
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div style="position:absolute; right:70px; top:60px;">
                        	<button class="btn btn-info" id="balancesearch"  type="button">余额查询</button>
                        	<button class="btn btn-info" id="accountsearch"  type="button">账户查询</button>
                        </div>
                        <!-- end toolbar -->
                        <div class="example">
                            <table id="driverTab" class="table" data-height="700" data-click-to-select="true" data-mobile-responsive="true">
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- End Panel Other -->
<script src="${pageContext.request.contextPath}/js/jquery.min.js?v=2.1.4"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${pageContext.request.contextPath}/js/content.min.js?v=1.0.0"></script>
<script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="${pageContext.request.contextPath}/js/plugins/layer/layer.min.js"></script>
<script src="${pageContext.request.contextPath}/js/public/ttbj-core.js"></script>

<script type="text/javascript">
var $table = $("#driverTab");
$(function () {
    initTable();
    //查询事件
    $("#queryDriverBtn").click(function () {
        $table.bootstrapTable('refresh');
    });
    //增加按钮
    $("#addBut").click(function () {
    	initDriverEdit(null);
    });
  //账户查询
    $("#accountsearch").click(function () {
    	var selectContent = $table.bootstrapTable('getSelections')[0];
        if(typeof(selectContent) == 'undefined') {
        	layer.msg('请选择一条数据!');
            return false;
        }else{
        	var driverAccountNo = selectContent.driverAccountNo;
        	if(driverAccountNo== ''||driverAccountNo== null||driverAccountNo== undefined){
        		layer.msg('还没有账户号');
        	}
        	else{
        		var index = layer.open({ 
                    type: 2,
                    title: "账户查询",
                    maxmin: true,
                    shadeClose: false, //点击遮罩关闭层
                    area : ['500px' , '750px'],
                    content: '../driver/driver_acc_query.htm?driverAccountNo='+driverAccountNo,
                    success: function(layero, index){
                    }
                }); 
        	}
        }
    });
  //余额查询
    $("#balancesearch").click(function () {
    	var selectContent = $table.bootstrapTable('getSelections')[0];
        if(typeof(selectContent) == 'undefined') {
        	layer.msg('请选择一条数据!');
            return false;
        }else{
        	var driverAccountNo = selectContent.driverAccountNo;
        	if(driverAccountNo== ''||driverAccountNo== null||driverAccountNo== undefined){
        		layer.msg('还没有账户号');
        	}
        	else{
        		var index = layer.open({ 
                    type: 2,
                    title: "余额查询",
                    maxmin: true,
                    shadeClose: false, //点击遮罩关闭层
                    area : ['500px' , '750px'],
                    content: '../driver/driver_balance.htm?driverAccountNo='+driverAccountNo,
                    success: function(layero, index){
                    }
                }); 
        	}
        }
    });
});

function initTable() {
    $table.bootstrapTable({
        dataType: "json",
        pagination: true, //分页
        striped: true,
        cache: false,	//是否使用缓存，默认是true
        showColumns: true,
        singleSelect : true,
        pageSize: 10,
        pageNumber: 1,
        queryParamsType: 'limit',
        smartDisplay: true,
        sidePagination: "server",
        method: "post",	//使用post提交
        queryParams: queryParams,
        url: '../driver/getDriverInfoByPage.htm',
        contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
        columns: [
			{
				title: "序号",
			    align: 'center',
			    formatter:function(value,row,index){
			    	return index + 1;
			    }
			},
			{
                checkbox: true,
                align: 'center',
                valign: 'middle'
            },
            {
                title: "用户名",
                field: "driverName",
                align: 'center',
                valign: 'middle'

            },
            {
                title: "真实姓名",
                field: "driverRealName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "驾照",
                field: "driverLicence",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "身份证",
                field: "driverIdcard",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "手机号",
                field: "driverPhone",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "注册时间",
                field: "driverInsTime",
                align: 'center',
                valign: 'middle'
            },
            {
            	title: "开户人",
                field: "driverCardName",
                align: 'center',
                valign: 'middle',
                visible: false
            },
            {
            	title: "开户卡号",
                field: "driverCardNo",
                align: 'center',
                valign: 'middle',
                visible: false
            },
            {
            	title: "开户行",
                field: "driverAccBank",
                align: 'center',
                valign: 'middle',
                visible: false
            },
            {
            	title: "开户手机号",
                field: "driverMobileNo",
                align: 'center',
                valign: 'middle',
                visible: false
            },
            {
            	title: "开户身份证",
                field: "driverAccIdCard",
                align: 'center',
                valign: 'middle',
                visible: false
            },
            {
            	title: "账户号",
                field: "driverAccountNo",
                align: 'center',
                valign: 'middle',
                visible: false
            },
            {
            	title: "审核",
            	field: "driverToExamine",
            	align: "center",
            	formatter: function(value, row, index){
            		<shiro:hasPermission name="driver:add">
            		var desc = '';
            		if(row.driverToExamine == 0){
            			desc = '<span style="color:#436EEE;">未审核</span>';
            		}else if(row.driverToExamine == 1){
            			desc = '<span style="color:#00CD00;">审核通过</span>';
            		}else if(row.driverToExamine == 2){
            			desc = '<span style="color:#ED5565;">审核未通过</span>';
            		}
            		return desc;
            		</shiro:hasPermission>
            	}
            },{
            	title: "司机类型",
            	field: "driverIsCompany",
            	align: "center",
            	formatter: function(value, row, index){
            		var type = '';
            		if(row.driverIsCompany == 0){
            			type = '<span style="color:#EE4000;">公司司机</span>';
            		}else if(row.driverIsCompany == 1){
            			type = '<span style="color:#CD6090;">社会司机</span>';
            		}else {
            			type = '';
            		}
            		return type;
            	}
            },
            {
                title: "操作",
                align: 'center',
                formatter: function (value, row, index) {
					<shiro:hasPermission name="driver:add">
                    var d = '';
                    var e = '';
                    if (row.driverIsDelete == 1){
                        d = '<button class="btn btn-xs btn-info" type="button" onclick="deleteDriver(\'' + row.driverNum + '\',\'' + row.driverName + '\',\'' + 1 + '\')"><i class="fa fa-trash-o"></i> 禁用 </button> ';
                    }else if(row.driverIsDelete == 0){
                    	d = '<button class="btn btn-xs btn-danger" type="button" onclick="deleteDriver(\'' + row.driverNum + '\',\'' + row.driverName + '\',\'' + 0 + '\')"><i class="fa fa-trash-o"></i> 启用 </button> ';
                    }
                    if (row.driverToExamine == 0){
                    	e = '<button class="btn btn-xs btn-danger" type="button" onclick="toExamineDriver(\'' + row.driverId + '\',\'' + row.driverToExamine + '\')"><i class="fa fa-trash-o"></i> 审核 </button> ';
                    }else if(row.driverToExamine == 1 || row.driverToExamine == 2){
                    	e = '<button class="btn btn-xs btn-info" type="button" onclick="toExamineDriver(\'' + row.driverId + '\',\'' + row.driverToExamine + '\')"><i class="fa fa-trash-o"></i> 详情 </button> ';
                    }
                    return d + e;
	              </shiro:hasPermission>
                }
            }
        ]
    });
}


//分页参数，条件查询时的参数
function queryParams(queryParamsType){
	var temp = {
		limit: queryParamsType.limit,   //页面大小
		offset: queryParamsType.offset,  //页码
		driverRealName: $.trim($('#driverRealName').val()),
		driverPhone: $.trim($('#driverPhone').val()),
		driverToExamine: $.trim($('#driverToExamine').val())
	};
	return temp;
}

//编辑司机信息
function initDriverEdit(id){
    var title;
    if(id){
        title = '编辑司机';
    }else{
        title = '新增司机';
    }
    var index = layer.open({
        type: 2,
        title: title,
        maxmin: true,
        shadeClose: false, //点击遮罩关闭层
        area : ['500px' , '700px'],
        content: '../driver/short_edit_driver.htm?id='+id,
        success: function(layero, index){
        }
    });
}


//短运司机信息审核
function toExamineDriver(driverId, status) {
	var title = '';
	if(status == 0){
		title = '司机信息审核';
	}else {
		title = '司机信息详情';
	}
	var index = layer.open({
        type: 2,
        title: title,
        maxmin: true,
        shadeClose: false, //点击遮罩关闭层
        area : ['700px' , '700px'],
        content: '../driver/shortdriver_info.htm?id='+ driverId + '&status=' + status,
        success: function(layero, index){
        }
    });
}

//设置短运司机状态
function deleteDriver(driverNum, driverName, isDelete) {
    layer.confirm('你确定要禁用/启用【' + driverName + '】吗？', {
        btn: ['确定', '取消'] //按钮
    }, function () {
        $.ajax({
            url: "../driver/editShortDriverDisable.htm",
            cache: false,
            type: "get",
            dataType: "json",
            data: {'driverNum': driverNum, "isDelete": isDelete},
            success: function (result) {
                if (result.status == 0) {
                    layer.msg(result.message, {icon: 1});
                    $table.bootstrapTable('refresh', {url: '../driver/getShortDriverInfoByPage.htm'});
                    return;
                }
                layer.msg(result.message, {icon: 2});
            }
        });
    }, function () {
    });
}
</script>
</body>
</html>
